/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Calendar;

/**
 * <p>Project: jse2204 - D3
 * <p>Powered by webrx On 2022-08-31 09:26:26
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class D3 {
    public static void main(String[] args) {
        Calendar c = Calendar.getInstance();
        //c.set();
        //2001 6 18
        //c.set(2001,6-1,18);
        //System.out.printf("%tF %<tT %<tA%n",c);

        //c.add();
        //今天5天前日期
        c.add(Calendar.DATE,-5);
        System.out.printf("%tF %<tT %<tA%n",c);

        //今天的7天后日期
        c.setTimeInMillis(System.currentTimeMillis());
        c.add(Calendar.DATE,7);
        System.out.printf("%tF %<tT %<tA%n",c);



        //3.计算多少天
        //c.set(2002,5-1,1); //出生那天
        //c.get();
        //var c2  = System.currentTimeMillis(); //今天
        //System.out.println((c2-c.getTimeInMillis())/(1000*60*60*24));

        var c3 = Calendar.getInstance();
        //c3.getTime(); 返回一个Date
        //System.out.println(c3.getTime());

        //获取时间戳
        //System.out.println(c3.getTimeInMillis());


        System.out.println(c3.get(Calendar.YEAR));
        System.out.printf("%02d%n",c3.get(Calendar.MONTH)+1);
        System.out.println(c3.get(Calendar.DATE));
        System.out.println(c3.get(Calendar.HOUR_OF_DAY));
        System.out.println(c3.get(Calendar.MINUTE));
        System.out.println(c3.get(Calendar.SECOND));
        System.out.println(c3.get(Calendar.MILLISECOND));


    }
}
